home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / ScreenSaver / Q3ADUtilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  2.6 KB  |  123 lines  |  [TEXT/CWIE]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        Q3ADUtilities.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Implements an After Dark Module using QuickDraw 3D.         **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1997 Apple Computer, Inc.  All rights reserved.         **
  11.  **                                                                             **
  12.  **        Portions Copyright (C) 1995 Berkeley Systems Inc.                     **
  13.  **                                                                          **
  14.  **                                                                          **
  15.  *****************************************************************************/
  16.  
  17. #ifndef Q3ADUtilities_h
  18. #define Q3ADUtilities_h
  19.  
  20. #if PRAGMA_ONCE
  21.     #pragma once
  22. #endif
  23.  
  24. #include "GraphicsModule_Types.h"
  25.  
  26. #include <Errors.h>
  27.  
  28. #include <QD3D.h>
  29. #include <QD3DRenderer.h>
  30. #include <QD3DDrawContext.h>
  31. #include <QD3DShader.h>
  32.  
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif    /* __cplusplus */
  37.  
  38. #if 0
  39. #pragma mark GLOBALS
  40. #endif
  41. /*
  42. **    GLOBALS for the following functions
  43. */
  44. extern unsigned long    gCurrentTicks;
  45.  
  46. #if 0
  47. #pragma mark PUBLIC STRUCTURES
  48. #endif
  49.  
  50. typedef struct iTQ3ADOffscreen    TQ3ADOffscreen;
  51.  
  52. #if 0
  53. #pragma mark FUNCTION DECLARATIONS
  54. #endif
  55.  
  56. TQ3ADOffscreen             *Offscreen_New(
  57.                             CGrafPtr        inDestPort,
  58.                             const Rect        *inDestRect,
  59.                             long            inDithered);
  60.                             
  61. TQ3Status                Offscreen_Dispose(
  62.                             TQ3ADOffscreen    *ioOffscreen);
  63.                             
  64. TQ3Status                Offscreen_Blit(
  65.                             TQ3ADOffscreen *inOffscreen);
  66.             
  67. TQ3DrawContextObject    Offscreen_NewPixmapDrawContext(
  68.                             TQ3ADOffscreen *inOffscreen);
  69.  
  70. TQ3RendererObject        Q3ADUtility_NewRenderer(
  71.                             void);
  72.                             
  73. TQ3DrawContextObject    Q3ADUtility_NewMacDrawContext(
  74.                             CGrafPtr port,
  75.                             float paneSize);
  76.                             
  77. TQ3ShaderObject            Q3ADUtility_NewShader(
  78.                             void);
  79.  
  80.  
  81. float                    Q3ADUtility_GetNumInRange(
  82.                             float number,
  83.                             float offset,
  84.                             float width);
  85.  
  86. Rect                    Q3ADUtility_GetRectOfBestMonitor(
  87.                             MonitorsInfoPtr monitorsInfo);
  88.             
  89. long                    Q3ADUtility_GetBestMonitor(
  90.                             MonitorsInfoPtr monitorsInfo);
  91.                             
  92. OSErr                    TQ3Status_to_OSErr(
  93.                             TQ3Status inStatus);
  94.  
  95.  
  96.  
  97. #if 0
  98. #pragma mark MACROS
  99. #endif
  100.  
  101. #define mUnused(x)    x
  102.  
  103. #define mBailIfNULL_(x)    if ((x) == NULL)    {status = kQ3Failure; goto bail; }
  104.  
  105. #define mBailIfNot_(x)    if (!(x))            {status = kQ3Failure; goto bail; }
  106.  
  107.  
  108. #define    mQ3ADUtility_Begin(x)                {gCurrentTicks = TickCount(); }
  109.  
  110. #define    mQ3ADUtility_End(x)
  111.  
  112. #define    mQ3ADUtility_GetSinOfTicks(x)    (float)sin(mQ3ADUtility_GetPulse(x))
  113.  
  114. #define    mQ3ADUtility_GetPulse(x)        (float)(gCurrentTicks % (long)x) \
  115.                                             * (6.2857142857/(long)x)
  116.  
  117.  
  118. #ifdef __cplusplus
  119. }
  120. #endif    /* __cplusplus */
  121.  
  122. #endif  /*  Q3ADUtilities_h  */
  123.